package com.lion.ball.modules.orderfood.service.assistants.converters;

import java.sql.Timestamp;
import com.lion.common.base.utils.ConvertUtil;
import com.lion.common.base.utils.DbUtil;
import com.lion.common.spring.annotations.DataConverter;
import com.lion.common.spring.business.base.BaseConverter;
import com.lion.utils.TimeUtil;
import com.lion.ball.modules.orderfood.domain.entity.OfdFoodSkuEntity;
import com.lion.ball.modules.orderfood.web.model.params.create.OfdFoodSkuCreateParam;
import com.lion.ball.modules.orderfood.web.model.params.update.OfdFoodSkuUpdateParam;
import com.lion.ball.modules.orderfood.web.model.results.OfdFoodSkuResult;

/**
 * @author Chris Chan
 * Create on 2025-10-18 13:33
 * Use for: 食品SKU 业务数据转换助手
 * Explain:
 * 
 */
@DataConverter
public class OfdFoodSkuConverter implements BaseConverter<
        OfdFoodSkuEntity,
        OfdFoodSkuCreateParam,
        OfdFoodSkuUpdateParam,
        OfdFoodSkuResult> {
    @Override
    public OfdFoodSkuEntity fromParam(OfdFoodSkuCreateParam param) {
        OfdFoodSkuEntity entity = new OfdFoodSkuEntity();
        ConvertUtil.copyProperties(param, entity, "id");
        // 生成编码
        entity.setCode(DbUtil.buildCode());
        return entity;
    }

    @Override
    public OfdFoodSkuEntity fromUpdateParam(OfdFoodSkuUpdateParam param) {
        OfdFoodSkuEntity entity = ConvertUtil.convert(param, OfdFoodSkuEntity.class);
        return entity;
    }

    @Override
    public OfdFoodSkuResult toResult(OfdFoodSkuEntity entity) {
        OfdFoodSkuResult result = ConvertUtil.convert(entity,OfdFoodSkuResult.class);
        return result;
    }
}